<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link>|
      <router-link to="/about">About</router-link>|
      <router-link to="/carousel">carousel</router-link>|
      <router-link to="/pdfsdy">pdfsdy</router-link>|
      <router-link to="/upload">upload</router-link>|
      <router-link to="/tree">tree</router-link>|
      <router-link to="/span_add">span_add</router-link>|
      <router-link to="/download">download</router-link>|
      <router-link to="/slide">slide</router-link>|
      <router-link to="/echart">echart</router-link>|
      <router-link to="/charts">charts</router-link>|
      <router-link to="/symbols">symbols</router-link>|
      <router-link to="/canyon">canyon</router-link>|
      <router-link to="/webgl">webgl</router-link>
    </div>

    <el-dropdown @command="handleCommand" class="home_dropdown">
      <span class="el-dropdown-link">
        下拉菜单
        <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item
          v-for="item in routeList"
          :key="item.path"
          :command="item.path"
        >{{item.name}}</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>

    <router-view />
  </div>
</template>

<script>
export default {
  data() {
    return {
      routeList: [],
    };
  },
  methods: {
    handleCommand(command) {
      this.$router.push({
        path: command,
      });
    },
  },
  created() {
    this.routeList = this.$router.options.routes;
  },
};
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
.home_dropdown {
  margin-bottom: 30px;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
